home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / CIncludes / ATA.h < prev    next >
C/C++ Source or Header  |  1996-05-01  |  53KB  |  1,009 lines

  1. /*
  2.      File:        ATA.h
  3.  
  4.      Contains:    ATA (PC/AT Attachment) Interfaces
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18. #ifndef __ATA__
  19. #define __ATA__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27.  
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31.  
  32. #if PRAGMA_IMPORT_SUPPORTED
  33. #pragma import on
  34. #endif
  35.  
  36. #if PRAGMA_ALIGN_SUPPORTED
  37. #pragma options align=mac68k
  38. #endif
  39.  
  40. #if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
  41. /* This is the structure used for the AT Interface core routines below */
  42.  
  43. enum {
  44.     kATATrap                    = 0xAAF1,                        /* Manager trap number <This should be defined in Traps.h>*/
  45.     kATAPBVers1                    = 0x01,                            /* parameter block version number 1*/
  46.     kATAPBVers2                    = 0x02,                            /* parameter block version number for structures*/
  47.     kATAPBVers3                    = 0x03,                            /* parameter block version for ATA times*/
  48.     kATADefaultBlockSize        = 512                            /* default block size*/
  49. };
  50.  
  51. /* Used to determine the presence of traps*/
  52.  
  53. enum {
  54.     kFSMTrap                    = 0xAC,
  55.     mDQEChanged                    = 1                                /* DQE has changed */
  56. };
  57.  
  58. /* Task file definition *** Error Register ****/
  59.  
  60. enum {
  61.     bATABadBlock                = 7,                            /* bit number of bad block error bit*/
  62.     bATAUncorrectable            = 6,                            /* bit number of uncorrectable error bit*/
  63.     bATAMediaChanged            = 5,                            /* bit number of media changed indicator*/
  64.     bATAIDNotFound                = 4,                            /* bit number of ID not found error bit*/
  65.     bATAMediaChangeReq            = 3,                            /* bit number of media changed request*/
  66.     bATACommandAborted            = 2,                            /* bit number of command abort bit*/
  67.     bATATrack0NotFound            = 1,                            /* bit number of track not found*/
  68.     bATAAddressNotFound            = 0,                            /* bit number of address mark not found*/
  69.     mATABadBlock                = 1 << bATABadBlock,            /* Bad Block Detected*/
  70.     mATAUncorrectable            = 1 << bATAUncorrectable,        /* Uncorrectable Data Error*/
  71.     mATAMediaChanged            = 1 << bATAMediaChanged,        /* Media Changed Indicator (for removable)*/
  72.     mATAIDNotFound                = 1 << bATAIDNotFound,            /* ID Not Found*/
  73.     mATAMediaChangeReq            = 1 << bATAMediaChangeReq,        /* Media Change Requested (NOT IMPLEMENTED)*/
  74.     mATACommandAborted            = 1 << bATACommandAborted,        /* Aborted Command*/
  75.     mATATrack0NotFound            = 1 << bATATrack0NotFound,        /* Track 0 Not Found*/
  76.     mATAAddressNotFound            = 1 << bATAAddressNotFound        /* Address Mark Not Found*/
  77. };
  78.  
  79. /* Task file definition *** ataTFSDH Register ****/
  80.  
  81. enum {
  82.     mATAHeadNumber                = 0x0F,                            /* Head Number (bits 0-3) */
  83.     mATASectorSize                = 0xA0,                            /* bit 7=1; bit 5 = 01 (512 sector size) <DP4>*/
  84.     mATADriveSelect                = 0x10,                            /* Drive (0 = master, 1 = slave) */
  85.     mATALBASelect                = 0x40                            /* LBA mode bit (0 = chs, 1 = LBA)*/
  86. };
  87.  
  88. /* Task file definition *** Status Register ****/
  89.  
  90. enum {
  91.     bATABusy                    = 7,                            /* bit number of BSY bit*/
  92.     bATADriveReady                = 6,                            /* bit number of drive ready bit*/
  93.     bATAWriteFault                = 5,                            /* bit number of write fault bit*/
  94.     bATASeekComplete            = 4,                            /* bit number of seek complete bit*/
  95.     bATADataRequest                = 3,                            /* bit number of data request bit*/
  96.     bATADataCorrected            = 2,                            /* bit number of data corrected bit*/
  97.     bATAIndex                    = 1,                            /* bit number of index mark*/
  98.     bATAError                    = 0,                            /* bit number of error bit*/
  99.     mATABusy                    = 1 << bATABusy,                /* Unit is busy*/
  100.     mATADriveReady                = 1 << bATADriveReady,            /* Unit is ready*/
  101.     mATAWriteFault                = 1 << bATAWriteFault,            /* Unit has a write fault condition*/
  102.     mATASeekComplete            = 1 << bATASeekComplete,        /* Unit seek complete*/
  103.     mATADataRequest                = 1 << bATADataRequest,            /* Unit data request*/
  104.     mATADataCorrected            = 1 << bATADataCorrected,        /* Data corrected*/
  105.     mATAIndex                    = 1 << bATAIndex,                /* Index mark - NOT USED*/
  106.     mATAError                    = 1 << bATAError                /* Error condition - see error register*/
  107. };
  108.  
  109. /* ATA Command Opcode definition*/
  110.  
  111. enum {
  112.     kATAcmdWORetry                = 0x01,                            /* Without I/O retry option*/
  113.     kATAcmdNOP                    = 0x0000,                        /* NOP operation - media detect*/
  114.     kATAcmdRecal                = 0x0010,                        /* Recalibrate command */
  115.     kATAcmdRead                    = 0x0020,                        /* Read command */
  116.     kATAcmdReadLong                = 0x0022,                        /* Read Long command*/
  117.     kATAcmdWrite                = 0x0030,                        /* Write command */
  118.     kATAcmdWriteLong            = 0x0032,                        /* Write Long*/
  119.     kATAcmdReadVerify            = 0x0040,                        /* Read Verify command */
  120.     kATAcmdFormatTrack            = 0x0050,                        /* Format Track command */
  121.     kATAcmdSeek                    = 0x0070,                        /* Seek command */
  122.     kATAcmdDiagnostic            = 0x0090,                        /* Drive Diagnostic command */
  123.     kATAcmdInitDrive            = 0x0091,                        /* Init drive parameters command */
  124.     kATAcmdReadMultiple            = 0x00C4,                        /* Read multiple*/
  125.     kATAcmdWriteMultiple        = 0x00C5,                        /* Write multiple*/
  126.     kATAcmdSetRWMultiple        = 0x00C6,                        /* Set Multiple for Read/Write Multiple*/
  127.     kATAcmdReadDMA                = 0x00C8,                        /* Read DMA (with retries)*/
  128.     kATAcmdWriteDMA                = 0x00CA,                        /* Write DMA (with retries)*/
  129.     kATAcmdMCAcknowledge        = 0x00DB,                        /* Acknowledge media change - removable*/
  130.     kATAcmdStandbyImmed            = 0x00E0,                        /* Standby Immediate*/
  131.     kATAcmdIdleImmed            = 0x00E1,                        /* Idle Immediate*/
  132.     kATAcmdStandby                = 0x00E2,                        /* Standby*/
  133.     kATAcmdIdle                    = 0x00E3,                        /* Idle*/
  134.     kATAcmdReadBuffer            = 0x00E4,                        /* Read sector buffer command */
  135.     kATAcmdCheckPowerMode        = 0x00E5,                        /* Check power mode command    <04/04/94>*/
  136.     kATAcmdSleep                = 0x00E6,                        /* Sleep*/
  137.     kATAcmdWriteBuffer            = 0x00E8,                        /* Write sector buffer command */
  138.     kATAcmdDriveIdentify        = 0x00EC,                        /* Identify Drive command */
  139.     kATAcmdSetFeatures            = 0x00EF                        /* Set Features*/
  140. };
  141.  
  142. /* Set feature command opcodes*/
  143.  
  144. enum {
  145.     kATAEnableWriteCache        = 0x02,                            /*        Enable write cache*/
  146.     kATASetTransferMode            = 0x03,                            /*        Set transfer mode*/
  147.     kATASetPIOMode                = 0x08,                            /*        PIO Flow Control Tx Mode bit*/
  148.     kATAEnableECC                = 0x88,                            /*        ECC enable*/
  149.     kATAEnableRetry                = 0x99,                            /*        Retry enable*/
  150.     kATAEnableReadAhead            = 0xAA                            /*        Read look-ahead enable*/
  151. };
  152.  
  153. /* Device Register Images  (8 bytes) */
  154. struct ataTaskFile {
  155.     UInt8                             ataTFFeatures;                /* <-> Error(R) or ataTFFeatures(W) register image */
  156.     UInt8                             ataTFCount;                    /* <-> Sector count/remaining */
  157.     UInt8                             ataTFSector;                /* <-> Sector start/finish */
  158.     UInt8                             ataTFReserved;                /* reserved                    */
  159.     UInt16                             ataTFCylinder;                /* <-> ataTFCylinder (Big endian) */
  160.     UInt8                             ataTFSDH;                    /* <-> ataTFSDH register image*/
  161.     UInt8                             ataTFCommand;                /* <-> Status(R) or Command(W) register image */
  162. };
  163. typedef struct ataTaskFile ataTaskFile;
  164.  
  165. /* ATA Manager Function Code Definition*/
  166.  
  167. enum {
  168.     kATAMgrNOP                    = 0x00,                            /* No Operation*/
  169.     kATAMgrExecIO                = 0x01,                            /* Execute ATA I/O*/
  170.     kATAMgrBusInquiry            = 0x03,                            /* Bus Inquiry*/
  171.     kATAMgrQRelease                = 0x04,                            /* I/O Queue Release*/
  172.     kATAMgrAbort                = 0x10,                            /* Abort command*/
  173.     kATAMgrBusReset                = 0x11,                            /* Reset ATA bus*/
  174.     kATAMgrRegAccess            = 0x12,                            /* Register Access*/
  175.     kATAMgrDriveIdentify        = 0x13,                            /* Drive Identify            <DP03/10/94>*/
  176.     kATAMgrDriverLoad            = 0x82,                            /* Load driver from either Media, ROM, etc.*/
  177.     kATAMgrDriveRegister        = 0x85,                            /* Register a driver        <4/18/94>*/
  178.     kATAMgrFindDriverRefnum        = 0x86,                            /* lookup a driver refnum    <4/18/94>*/
  179.     kATAMgrRemoveDriverRefnum    = 0x87,                            /* De-register a driver    <4/18/94>*/
  180.     kATAMgrModifyEventMask        = 0x88,                            /* Modify driver event mask*/
  181.     kATAMgrDriveEject            = 0x89,                            /* Eject the drive        <8/1/94>*/
  182.     kATAMgrGetDrvConfiguration    = 0x8A,                            /* Get device configuration    <8/6/94>*/
  183.     kATAMgrSetDrvConfiguration    = 0x8B,                            /* Set device configuration <8/6/94>*/
  184.     kATAMgrGetLocationIcon        = 0x8C,                            /* Get card location icon    <SM4>*/
  185.     kATAMgrManagerInquiry        = 0x90,                            /* Manager Inquiry*/
  186.     kATAMgrManagerInit            = 0x91,                            /* Manager initialization*/
  187.     kATAMgrManagerShutdown        = 0x92                            /* Manager ShutDown*/
  188. };
  189.  
  190. /* 'ATAFlags' field of the PB header definition*/
  191.  
  192. enum {
  193.     bATAFlagUseConfigSpeed        = 15,                            /* bit number of use default speed flag*/
  194.     bATAFlagByteSwap            = 14,                            /* bit number of byte swap flag*/
  195.     bATAFlagIORead                = 13,                            /* bit number of I/O read flag*/
  196.     bATAFlagIOWrite                = 12,                            /* bit number of I/O write flag*/
  197.     bATAFlagImmediate            = 11,                            /* bit number of immediate flag*/
  198.     bATAFlagQLock                = 10,                            /* bit number of que lock on error*/
  199.     bATAFlagScatterGather1        = 9,                            /* bit number of scatter gather*/
  200.     bATAFlagScatterGather0        = 8,                            /* bit numbers of scatter gather*/
  201.     bATAFlagUseDMA                = 7,                            /* bit number of use DMA flag*/
  202.     bATAFlagProtocol1            = 5,                            /* bit number of scatter gather*/
  203.     bATAFlagProtocol0            = 4,                            /* bit numbers of protocol specifier*/
  204.     bATAFlagTFRead                = 3,                            /* bit number of register update*/
  205.     bATAFlagLEDEnable            = 0,                            /* bit number of LED enable*/
  206.     mATAFlagUseConfigSpeed        = 1 << bATAFlagUseConfigSpeed,
  207.     mATAFlagByteSwap            = 1 << bATAFlagByteSwap,        /* Swap data bytes (read - after; write - before)*/
  208.     mATAFlagIORead                = 1 << bATAFlagIORead,            /* Read (in) operation*/
  209.     mATAFlagIOWrite                = 1 << bATAFlagIOWrite,            /* Write (out) operation*/
  210.     mATAFlagImmediate            = 1 << bATAFlagImmediate,        /* Head of Que; Immediate operation*/
  211.     mATAFlagQLock                = 1 << bATAFlagQLock,            /* Manager queue lock on error (freeze the queue)*/
  212.     mATAFlagScatterGather1        = 1 << bATAFlagScatterGather1,
  213.     mATAFlagScatterGather0        = 1 << bATAFlagScatterGather0,    /* Scatter gather enable*/
  214.     mATAFlagScatterGathers        = mATAFlagScatterGather1 + mATAFlagScatterGather0, /* host scatter gather type = currently type 1 supported*/
  215.     mATAFlagUseDMA                = 1 << bATAFlagUseDMA,
  216.     mATAFlagProtocol1            = 1 << bATAFlagProtocol1,        /* ATAPI protocol indicator <06/15/94>*/
  217.     mATAFlagProtocol0            = 1 << bATAFlagProtocol0,        /* PCMCIA protocol indicator <06/15/94>*/
  218.     mATAFlagProtocols            = mATAFlagProtocol1 + mATAFlagProtocol0, /* mask for protocol type field    <06/15/94>*/
  219.     mATAFlagTFRead                = 1 << bATAFlagTFRead,            /* update reg block request upon detection of an error*/
  220.     mATAFlagLEDEnable            = 1 << bATAFlagLEDEnable        /* socket LED enable*/
  221. };
  222.  
  223. /* Parameter block header definition - common for all PBs (48 bytes)*/
  224. typedef struct ataPBHeader ataPBHeader;
  225. struct ataPBHeader {
  226.                                                                 /* Start of cloned common header ataPBHdr */
  227.     struct ataPBHeader *            ataPBLink;                    /* a pointer to the next entry in the queue    */
  228.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  229.     UInt8                             ataPBVers;                    /* -->: parameter block version number*/
  230.     UInt8                             ataPBReserved;                /* Reserved                                        */
  231.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  232.     ProcPtr                         ataPBCallbackPtr;            /* -->: Completion Routine Pointer    */
  233.     OSErr                             ataPBResult;                /* <--: Returned result                */
  234.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  235.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  236.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  237.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  238.     UInt32                             ataPBDeviceID;                /* -->: Device identifier            */
  239.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  240.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  241.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  242.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  243.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  244.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  245.                                                                 /* End of cloned common header ataPBHdr*/
  246. };
  247. typedef struct ataPBHeader ataPBHeader;
  248.  
  249. /* data request entry structure (16 bytes)*/
  250. struct IOBlock {
  251.     UInt8 *                            ataPBBuffer;                /* -->: Data buffer pointer*/
  252.     UInt32                             ataPBByteCount;                /* -->: Data transfer length in bytes*/
  253. };
  254. typedef struct IOBlock IOBlock;
  255.  
  256. /*
  257.  For ATAPI devices the ExtendedPB field is a pointer to the Command Packet
  258.  record which exists of an array of words structured as follows...    <06/15/94>
  259. */
  260. struct ATAPICmdPacket {
  261.     SInt16                             atapiPacketSize;            /* Size of command packet in bytes    <06/15/94>*/
  262.     SInt16                             atapiCommandByte[8];        /* The command packet itself    <06/15/94>*/
  263. };
  264. typedef struct ATAPICmdPacket ATAPICmdPacket;
  265.  
  266. /* Manager parameter block structure (96 bytes)*/
  267. struct ataIOPB {
  268.                                                                 /* Start of cloned common header ataPBHdr*/
  269.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  270.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  271.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  272.     UInt8                             ataPBReserved;                /* Reserved                                        */
  273.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  274.     ProcPtr                         ataPBCallbackPtr;            /* -->: Completion Routine Pointer    */
  275.     OSErr                             ataPBResult;                /* <--: Returned result                */
  276.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  277.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  278.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  279.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  280.     UInt32                             ataPBDeviceID;                /* -->: Device identifier            */
  281.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  282.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  283.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  284.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  285.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  286.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  287.                                                                 /* End of cloned common header ataPBHdr*/
  288.     SInt8                             ataPBStatusRegister;        /* <--: Last ATA status image*/
  289.     SInt8                             ataPBErrorRegister;            /* <--: Last ATA error image-valid if lsb of Status set*/
  290.     SInt16                             ataPBReserved5;                /* Reserved*/
  291.     UInt32                             ataPBLogicalBlockSize;        /* -->: Blind transfer size per interrupt (Logical block size)*/
  292.     UInt8 *                            ataPBBuffer;                /* -->: Data buffer pointer*/
  293.     UInt32                             ataPBByteCount;                /* -->: Data transfer length in bytes*/
  294.     UInt32                             ataPBActualTxCount;            /* <--: Actual transfer count*/
  295.     UInt32                             ataPBReserved6;                /* Reserved*/
  296.     ataTaskFile                     ataPBTaskFile;                /* <->:    Device register images*/
  297.     ATAPICmdPacket *                ataPBPacketPtr;                /* -->: ATAPI packet command block pointer (valid with ATAPI bit set)*/
  298.     SInt16                             ataPBReserved7[6];            /* Reserved for future expansion*/
  299. };
  300. typedef struct ataIOPB ataIOPB;
  301.  
  302. /*
  303.  Parameter block structure for bus and Manager inquiry command
  304.  Manager parameter block structure
  305. */
  306. struct ataBusInquiry {
  307.                                                                 /* Start of cloned common header ataPBHdr*/
  308.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  309.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  310.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  311.     UInt8                             ataPBReserved;                /* Reserved                                        */
  312.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  313.     ProcPtr                         ataPBCallbackPtr;            /* -->: Completion Routine Pointer    */
  314.     OSErr                             ataPBResult;                /* <--: Returned result                */
  315.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  316.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  317.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  318.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  319.     UInt32                             ataPBDeviceID;                /* -->: Device identifier            */
  320.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  321.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  322.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  323.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  324.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  325.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  326.                                                                 /* End of cloned common header ataPBHdr*/
  327.     UInt16                             ataEngineCount;                /* <--: TBD; zero for now*/
  328.     UInt16                             ataPBReserved5;                /* Reserved*/
  329.     UInt32                             ataDataTypes;                /* <--: TBD; zero for now*/
  330.     UInt16                             ataIOpbSize;                /* <--: Size of ATA IO PB*/
  331.     UInt16                             ataMaxIOpbSize;                /* <--: TBD; zero for now*/
  332.     UInt32                             ataFeatureFlags;            /* <--: TBD*/
  333.     UInt8                             ataVersionNum;                /* <--: Version number for the HBA*/
  334.     UInt8                             ataHBAInquiry;                /* <--: TBD; zero for now*/
  335.     UInt16                             ataPBReserved6;                /* Reserved*/
  336.     UInt32                             ataHBAPrivPtr;                /* <--: Ptr to HBA private data area*/
  337.     UInt32                             ataHBAPrivSize;                /* <--: Size of HBA private data area*/
  338.     UInt32                             ataAsyncFlags;                /* <--: Event capability for callback*/
  339.     UInt32                             ataPBReserved7[4];            /* Reserved*/
  340.     UInt32                             ataReserved4;                /* Reserved*/
  341.     SInt8                             ataReserved5[16];            /* TBD*/
  342.     SInt8                             ataHBAVendor[16];            /* <--: Vendor ID of the HBA*/
  343.     SInt8                             ataContrlFamily[16];        /* <--: Family of ATA Controller*/
  344.     SInt8                             ataContrlType[16];            /* <--: Model number of controller*/
  345.     SInt8                             ataXPTversion[4];            /* <--: version number of XPT*/
  346.     SInt8                             ataResrved6[4];                /* Reserved*/
  347.     SInt8                             ataHBAversion[4];            /* <--: version number of HBA*/
  348.     UInt8                             ataHBAslotType;                /* <--: type of slot*/
  349.     UInt8                             ataHBAslotNum;                /* <--: slot number of the HBA*/
  350.     UInt16                             ataReserved7;                /* Reserved*/
  351.     UInt32                             ataReserved8;                /* Reserved*/
  352. };
  353. typedef struct ataBusInquiry ataBusInquiry;
  354.  
  355. /* Manager parameter block structure*/
  356. struct ataMgrInquiry {
  357.                                                                 /* Start of cloned common header ataPBHdr*/
  358.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  359.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  360.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  361.     UInt8                             ataPBReserved;                /* Reserved                                        */
  362.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  363.     ProcPtr                         ataPBCallbackPtr;            /* -->: Completion Routine Pointer    */
  364.     OSErr                             ataPBResult;                /* <--: Returned result                */
  365.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  366.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  367.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  368.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  369.     UInt32                             ataPBDeviceID;                /* -->: Device identifier            */
  370.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  371.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  372.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  373.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  374.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  375.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  376.                                                                 /* End of cloned common header ataPBHdr*/
  377.     NumVersion                         ataMgrVersion;                /* Manager Version information*/
  378.     UInt8                             ataMgrPBVers;                /* <--: Manager PB version number supported*/
  379.     UInt8                             Reserved1;                    /* Reserved*/
  380.     UInt16                             ataBusCnt;                    /* <--: Number of ATA buses in the system*/
  381.     UInt16                             ataDevCnt;                    /* <--: Total number of ATA devices detected*/
  382.     UInt8                             ataPioModes;                /* <--: Maximum Programmed I/O speed mode supported*/
  383.     UInt8                             Reserved2;                    /* Reserved*/
  384.     UInt16                             ataIOClkResolution;            /* <--: IO Clock resolution in nsec (Not supported)*/
  385.     UInt8                             ataSingleDMAModes;            /* <--: Single Word DMA modes supported    */
  386.     UInt8                             ataMultiDMAModes;            /* <--: Multiword DMA modes supported*/
  387.     SInt16                             Reserved[16];                /* Reserved for future expansion*/
  388. };
  389. typedef struct ataMgrInquiry ataMgrInquiry;
  390.  
  391. /*
  392.  Parameter block structure for Abort command
  393.  Manager parameter block structure
  394. */
  395. struct ataAbort {
  396.                                                                 /* Start of cloned common header ataPBHdr*/
  397.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  398.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  399.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  400.     UInt8                             ataPBReserved;                /* Reserved                                        */
  401.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  402.     ProcPtr                         ataPBCallbackPtr;            /* -->: Completion Routine Pointer    */
  403.     OSErr                             ataPBResult;                /* <--: Returned result                */
  404.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  405.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  406.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  407.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  408.     UInt32                             ataPBDeviceID;                /* -->: Device identifier            */
  409.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  410.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  411.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  412.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  413.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  414.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  415.                                                                 /* End of cloned common header ataPBHdr*/
  416.     ataIOPB *                        ataAbortPB;                    /* -->: Parameter block to be aborted*/
  417.     SInt16                             Reserved[22];                /* Reserved for future expansion*/
  418. };
  419. typedef struct ataAbort ataAbort;
  420.  
  421. /* Manager parameter block structure*/
  422. struct ATAEventRec {
  423.     UInt16                             ataEventCode;                /* --> ATA event code*/
  424.     UInt16                             ataPhysicalID;                /* --> Physical drive reference*/
  425.     SInt32                             ataDrvrContext;                /* Context pointer saved by driver*/
  426. };
  427. typedef struct ATAEventRec ATAEventRec;
  428.  
  429. typedef ATAEventRec *ATAEventRecPtr;
  430. typedef pascal SInt16 (*ATAClientProcPtr)(ATAEventRecPtr ataERPtr);
  431.  
  432. #if GENERATINGCFM
  433. typedef UniversalProcPtr ATAClientUPP;
  434. #else
  435. typedef ATAClientProcPtr ATAClientUPP;
  436. #endif
  437.  
  438. enum {
  439.     uppATAClientProcInfo = kPascalStackBased
  440.          | RESULT_SIZE(SIZE_CODE(sizeof(SInt16)))
  441.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ATAEventRecPtr)))
  442. };
  443.  
  444. #if GENERATINGCFM
  445. #define NewATAClientProc(userRoutine)        \
  446.         (ATAClientUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppATAClientProcInfo, GetCurrentArchitecture())
  447. #else
  448. #define NewATAClientProc(userRoutine)        \
  449.         ((ATAClientUPP) (userRoutine))
  450. #endif
  451.  
  452. #if GENERATINGCFM
  453. #define CallATAClientProc(userRoutine, ataERPtr)        \
  454.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppATAClientProcInfo, (ataERPtr))
  455. #else
  456. #define CallATAClientProc(userRoutine, ataERPtr)        \
  457.         (*(userRoutine))((ataERPtr))
  458. #endif
  459. /*
  460.  Parameter block structure for Driver Register command
  461.  Manager parameter block structure
  462. */
  463. struct ataDrvrRegister {
  464.                                                                 /* Start of cloned common header ataPBHdr*/
  465.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  466.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  467.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  468.     UInt8                             ataPBReserved;                /* Reserved                                        */
  469.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  470.     ProcPtr                         ataPBCallbackPtr;            /* -->: Completion Routine Pointer    */
  471.     OSErr                             ataPBResult;                /* <--: Returned result                */
  472.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  473.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  474.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  475.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  476.     UInt32                             ataPBDeviceID;                /* -->: Device identifier            */
  477.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  478.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  479.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  480.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  481.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  482.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  483.                                                                 /* End of cloned common header ataPBHdr*/
  484.     SInt16                             ataDrvrRefNum;                /* <->: Driver reference number*/
  485.     UInt16                             ataDrvrFlags;                /* -->: 1 = loader driver if ataPBDeviceID = -1 {PB2}*/
  486.     UInt16                             ataDeviceNextID;            /* <--: used to specified the next drive ID*/
  487.     SInt16                             ataDrvrLoadPriv;            /* Driver loader private storage*/
  488.     ATAClientUPP                     ataEventHandler;            /* <->: Pointer to ATA event callback routine {PB2}*/
  489.     SInt32                             ataDrvrContext;                /* <->: Context data saved by driver {PB2}*/
  490.     SInt32                             ataEventMask;                /* <->: Set to 1 for notification of event {PB2}*/
  491.     SInt16                             Reserved[14];                /* Reserved for future expansion - from [21] {PB2}*/
  492. };
  493. typedef struct ataDrvrRegister ataDrvrRegister;
  494.  
  495. /* Parameter block structure for Modify driver event mask command*/
  496. struct ataModifyEventMask {
  497.                                                                 /* Start of cloned common header ataPBHdr*/
  498.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  499.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  500.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  501.     UInt8                             ataPBReserved;                /* Reserved                                        */
  502.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  503.     ProcPtr                         ataPBCallbackPtr;            /* -->: Completion Routine Pointer    */
  504.     OSErr                             ataPBResult;                /* <--: Returned result                */
  505.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  506.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  507.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  508.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  509.     UInt32                             ataPBDeviceID;                /* -->: Device identifier            */
  510.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  511.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  512.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  513.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  514.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  515.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  516.                                                                 /* End of cloned common header ataPBHdr*/
  517.     SInt32                             ataModifiedEventMask;        /* -->: new event mask value*/
  518.     SInt16                             Reserved[22];                /* Reserved for future expansion*/
  519. };
  520. typedef struct ataModifyEventMask ataModifyEventMask;
  521.  
  522. /* 'ataRegMask' field of the ataRegAccess definition*/
  523.  
  524. enum {
  525.     bATAAltSDevCValid            = 14,                            /* bit number of alternate status/device cntrl valid bit*/
  526.     bATAStatusCmdValid            = 7,                            /* bit number of status/command valid bit*/
  527.     bATASDHValid                = 6,                            /* bit number of ataTFSDH valid bit*/
  528.     bATACylinderHiValid            = 5,                            /* bit number of cylinder high valid bit*/
  529.     bATACylinderLoValid            = 4,                            /* bit number of cylinder low valid bit*/
  530.     bATASectorNumValid            = 3,                            /* bit number of sector number valid bit*/
  531.     bATASectorCntValid            = 2,                            /* bit number of sector count valid bit*/
  532.     bATAErrFeaturesValid        = 1,                            /* bit number of error/features valid bit*/
  533.     bATADataValid                = 0,                            /* bit number of data valid bit*/
  534.     mATAAltSDevCValid            = 1 << bATAAltSDevCValid,        /* alternate status/device control valid*/
  535.     mATAStatusCmdValid            = 1 << bATAStatusCmdValid,        /* status/command valid*/
  536.     mATASDHValid                = 1 << bATASDHValid,            /* ataTFSDH valid*/
  537.     mATACylinderHiValid            = 1 << bATACylinderHiValid,        /* cylinder high valid*/
  538.     mATACylinderLoValid            = 1 << bATACylinderLoValid,        /* cylinder low valid*/
  539.     mATASectorNumValid            = 1 << bATASectorNumValid,        /* sector number valid*/
  540.     mATASectorCntValid            = 1 << bATASectorCntValid,        /* sector count valid*/
  541.     mATAErrFeaturesValid        = 1 << bATAErrFeaturesValid,    /* error/features valid*/
  542.     mATADataValid                = 1 << bATADataValid            /* data valid*/
  543. };
  544.  
  545. /* Parameter block structure for device register access command*/
  546. union ataRegValueUnion {
  547.     UInt8                             ataByteRegValue;            /* <->: Byte register value read or to be written*/
  548.     UInt16                             ataWordRegValue;            /* <->: Word register value read or to be written*/
  549. };
  550. typedef union ataRegValueUnion ataRegValueUnion;
  551.  
  552. /* Manager parameter block structure*/
  553. struct ataRegAccess {
  554.                                                                 /* Start of cloned common header ataPBHdr*/
  555.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  556.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  557.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  558.     UInt8                             ataPBReserved;                /* Reserved                                        */
  559.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  560.     ProcPtr                         ataPBCallbackPtr;            /* -->: Completion Routine Pointer    */
  561.     OSErr                             ataPBResult;                /* <--: Returned result                */
  562.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  563.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  564.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  565.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  566.     UInt32                             ataPBDeviceID;                /* -->: Device identifier            */
  567.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  568.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  569.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  570.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  571.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  572.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  573.                                                                 /* End of cloned common header ataPBHdr*/
  574.     UInt16                             ataRegSelect;                /* -->: Device Register Selector*/
  575.                                                                 /*            DataReg            0    */
  576.                                                                 /*            ErrorReg(R) or FeaturesReg(W)    1*/
  577.                                                                 /*            SecCntReg        2*/
  578.                                                                 /*            SecNumReg        3*/
  579.                                                                 /*            CylLoReg        4*/
  580.                                                                 /*            CylHiReg        5*/
  581.                                                                 /*            SDHReg            6*/
  582.                                                                 /*            StatusReg(R) or CmdReg(W)        7*/
  583.                                                                 /*            AltStatus(R) or DevCntr(W)    0E*/
  584.     ataRegValueUnion                 ataRegValue;
  585.                                                                 /* Following fields are valid only if ataRegSelect = 0xFFFF*/
  586.     UInt16                             ataRegMask;                    /* -->: mask for register(s) to update*/
  587.                                                                 /*        bit 0 : data register valid*/
  588.                                                                 /*        bit 1 : error/feaures register valid*/
  589.                                                                 /*        bit 2 : sector count register valid*/
  590.                                                                 /*        bit 3 : sector number register valid*/
  591.                                                                 /*        bit 4 : cylinder low register valid*/
  592.                                                                 /*        bit 5 : cylinder high register valid*/
  593.                                                                 /*        bit 6 : ataTFSDH register valid*/
  594.                                                                 /*        bit 7 : status/command register valid*/
  595.                                                                 /*        bits 8 - 13 : reserved (set to 0)*/
  596.                                                                 /*        bit 14: alternate status / device control reg valid*/
  597.                                                                 /*         bit 15: reserved (set to 0)*/
  598.     ataTaskFile                     ataRegisterImage;            /* <->: register images*/
  599.     UInt8                             ataAltSDevCReg;                /* <->: Alternate status(R) or Device Control(W) register image*/
  600.     UInt8                             Reserved3;                    /* Reserved*/
  601.     SInt16                             Reserved[16];                /* Reserved for future expansion*/
  602. };
  603. typedef struct ataRegAccess ataRegAccess;
  604.  
  605. /* Manager parameter block structure    <DP03/10/94>*/
  606. struct ataIdentify {
  607.                                                                 /* Start of cloned common header ataPBHdr*/
  608.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  609.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  610.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  611.     UInt8                             ataPBReserved;                /* Reserved                                        */
  612.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  613.     ProcPtr                         ataPBCallbackPtr;            /* -->: Completion Routine Pointer    */
  614.     OSErr                             ataPBResult;                /* <--: Returned result                */
  615.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  616.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  617.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  618.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  619.     UInt32                             ataPBDeviceID;                /* -->: Device identifier            */
  620.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  621.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  622.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  623.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  624.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  625.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  626.                                                                 /* End of cloned common header ataPBHdr*/
  627.     UInt16                             Reserved1[4];                /* Reserved.  These are used internally by the Manager*/
  628.     UInt8 *                            ataPBBuffer;                /* Buffer for the identify data (512 bytes)*/
  629.     UInt16                             Reserved2[12];                /* Used internally by the ATA Manager*/
  630.     SInt16                             Reserved3[6];                /* Reserved for future expansion*/
  631. };
  632. typedef struct ataIdentify ataIdentify;
  633.  
  634. /* 'ataConfigSetting' field of the Get/Set Device Configuration definition <8/6/94>*/
  635.  
  636. enum {
  637.     ATAPIpacketDRQ_bit            = 6,                            /* bit number of ATAPI command packet DRQ option*/
  638.     ATAPIpacketDRQ                = 1 << ATAPIpacketDRQ_bit        /* ATAPI command packet DRQ option*/
  639. };
  640.  
  641. /* atapcValid field definition*/
  642.  
  643. enum {
  644.     bATApcAccessMode            = 0,
  645.     bATApcVcc                    = 1,
  646.     bATApcVpp1                    = 2,
  647.     bATApcVpp2                    = 3,
  648.     bATApcStatus                = 4,
  649.     bATApcPin                    = 5,
  650.     bATApcCopy                    = 6,
  651.     bATApcConfigIndex            = 7,
  652.     bATApcLockUnlock            = 15,
  653.     mATApcAccessMode            = 1 << bATApcAccessMode,
  654.     mATApcVcc                    = 1 << bATApcVcc,
  655.     mATApcVpp1                    = 1 << bATApcVpp1,
  656.     mATApcVpp2                    = 1 << bATApcVpp2,
  657.     mATApcStatus                = 1 << bATApcStatus,
  658.     mATApcPin                    = 1 << bATApcPin,
  659.     mATApcCopy                    = 1 << bATApcCopy,
  660.     mATApcConfigIndex            = 1 << bATApcConfigIndex,
  661.     mATApcLockUnlock            = 1 << bATApcLockUnlock
  662. };
  663.  
  664. /* Device physical type & socket type indicator definition*/
  665.  
  666. enum {
  667.     kATADeviceUnknown            = 0x00,                            /* no device or type undetermined*/
  668.     kATADeviceATA                = 0x01,                            /* traditional ATA protocol device <7/29/94>*/
  669.     kATADeviceATAPI                = 0x02,                            /* ATAPI protocol device    <7/29/94>*/
  670.     kATADevicePCMCIA            = 0x03,                            /* PCMCIA ATA device        <7/29/94>*/
  671.     kATASocketInternal            = 0x01,                            /* Internal ATA socket*/
  672.     kATASocketMB                = 0x02,                            /* Media Bay socket*/
  673.     kATASocketPCMCIA            = 0x03,                            /* PCMCIA socket*/
  674.     kATAConfigReserved            = 7                                /* number of reserved words at the end*/
  675. };
  676.  
  677. /*
  678.  Get/Set Device Configuration parameter block structure <8/6/94>
  679.  Manager parameter block structure
  680. */
  681. struct ataDevConfiguration {
  682.                                                                 /* Start of cloned common header ataPBHdr*/
  683.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  684.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  685.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  686.     UInt8                             ataPBReserved;                /* Reserved                                        */
  687.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  688.     ProcPtr                         ataPBCallbackPtr;            /* -->: Completion Routine Pointer    */
  689.     OSErr                             ataPBResult;                /* <--: Returned result                */
  690.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  691.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  692.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  693.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  694.     UInt32                             ataPBDeviceID;                /* -->: Device identifier            */
  695.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  696.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  697.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  698.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  699.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  700.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  701.                                                                 /* End of cloned common header ataPBHdr*/
  702.     SInt32                             ataConfigSetting;            /* <->: Configuration setting*/
  703.                                                                 /*      Bits 3 - 0: Reserved*/
  704.                                                                 /*      Bit 4: Reserved (allowLBAAccess)*/
  705.                                                                 /*      Bit 5: Reserved (allowRWMultiple)*/
  706.                                                                 /*      Bit 6: ATAPIpacketDRQ*/
  707.                                                                 /*        1 = Check for Interrupt DRQ on ATAPI command packet DRQ*/
  708.                                                                 /*        0 = Default: Check only for the assertion of command packet DRQ*/
  709.                                                                 /*      Bits 31 - 7: Reserved*/
  710.     UInt8                             ataPIOSpeedMode;            /* <->: Device access speed in PIO Mode*/
  711.     UInt8                             Reserved3;                    /* Reserved to force word alignment*/
  712.     UInt16                             atapcValid;                    /* <->: Set when pcXXX fields are valid (atapcAccessMode - atapcConfigIndex)*/
  713.                                                                 /*        bit 0 - atapcAccessMode field valid, when set*/
  714.                                                                 /*        bit 1 - atapcVcc field valid, when set*/
  715.                                                                 /*        bit 2 - atapcVpp1 field valid, when set*/
  716.                                                                 /*        bit 3 - atapcVpp2 field valid, when set*/
  717.                                                                 /*        bit 4 - atapcStatus field valid, when set*/
  718.                                                                 /*        bit 5 - atapcPin field valid, when set*/
  719.                                                                 /*        bit 6 - atapcCopy field valid, when set*/
  720.                                                                 /*        bit 7 - atapcConfigIndex field valid, when set*/
  721.                                                                 /*        bits 14-8 - Reserved*/
  722.                                                                 /*        bit 15 - device lock/unlock request (write only)*/
  723.     UInt16                             ataRWMultipleCount;            /* Reserved for future (not supported yet)*/
  724.     UInt16                             ataSectorsPerCylinder;        /* Reserved for future (not supported yet)*/
  725.     UInt16                             ataHeads;                    /* Reserved for future (not supported yet)*/
  726.     UInt16                             ataSectorsPerTrack;            /* Reserved for future (not supported yet)*/
  727.     UInt16                             ataSocketNumber;            /* <--: Socket number used by the CardServices*/
  728.                                                                 /*        0xFF = socket number invalid (Not a CardServices device)*/
  729.                                                                 /*        other = socket number of the device*/
  730.     UInt8                             ataSocketType;                /* <--: Specifies the socket type (get config only)*/
  731.                                                                 /*        00 = Unknown socket*/
  732.                                                                 /*         01 = Internal ATA bus*/
  733.                                                                 /*        02 = Media Bay*/
  734.                                                                 /*        03 = PCMCIA*/
  735.     UInt8                             ataDeviceType;                /* <--: Specifies the device type (get config only)*/
  736.                                                                 /*        00 = Unknown device*/
  737.                                                                 /*        01 = standard ATA device (HD)*/
  738.                                                                 /*        02 = ATAPI device*/
  739.                                                                 /*        03 = PCMCIA ATA device*/
  740.     UInt8                             atapcAccessMode;            /* <->: Access mode: Memory vs. I/O (PCMCIA only)*/
  741.     UInt8                             atapcVcc;                    /* <->: Voltage in tenths of a volt (PCMCIA only)*/
  742.     UInt8                             atapcVpp1;                    /* <->: Voltage in tenths of a volt (PCMCIA only)*/
  743.     UInt8                             atapcVpp2;                    /* <->: Voltage in tenths of a volt (PCMCIA only)*/
  744.     UInt8                             atapcStatus;                /* <->: Card Status register setting (PCMCIA only)*/
  745.     UInt8                             atapcPin;                    /* <->: Card Pin register setting (PCMCIA only)*/
  746.     UInt8                             atapcCopy;                    /* <->: Card Socket/Copy register setting (PCMCIA only)*/
  747.     UInt8                             atapcConfigIndex;            /* <->: Card Option register setting (PCMCIA only)*/
  748.     UInt8                             ataSingleDMASpeed;            /* <->: Single Word DMA Timing Class*/
  749.     UInt8                             ataMultiDMASpeed;            /* <->: Multiple Word DMA Timing Class*/
  750.     UInt16                             ataPIOCycleTime;            /* <->:Cycle time for PIO mode*/
  751.     UInt16                             ataMultiCycleTime;            /* <->:Cycle time for Multiword DMA mode*/
  752.     UInt16                             Reserved1[7];                /* Reserved for future*/
  753. };
  754. typedef struct ataDevConfiguration ataDevConfiguration;
  755.  
  756. /* Get Card Location Icon/Text    <SM4>*/
  757.  
  758. enum {
  759.     kATALargeIconHFS            = 0x0001,                        /* Large B&W icon with mask (HFS)*/
  760.     kATALargeIconProDOS            = 0x0081                        /* Large B&W icon with mask (ProDOS)*/
  761. };
  762.  
  763. /* Manager parameter block structure*/
  764. struct ataLocationData {
  765.                                                                 /* Start of cloned common header ataPBHdr*/
  766.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  767.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  768.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  769.     UInt8                             ataPBReserved;                /* Reserved                                        */
  770.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  771.     ProcPtr                         ataPBCallbackPtr;            /* -->: Completion Routine Pointer    */
  772.     OSErr                             ataPBResult;                /* <--: Returned result                */
  773.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  774.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  775.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  776.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  777.     UInt32                             ataPBDeviceID;                /* -->: Device identifier            */
  778.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  779.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  780.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  781.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  782.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  783.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  784.                                                                 /* End of cloned common header ataPBHdr*/
  785.     SInt16                             ataIconType;                /* -->: icon type specifier*/
  786.                                                                 /*         1 = Large B&W icon with mask (256 bytes)*/
  787.                                                                 /*        0x81 = Same as 1, but ProDOS icon*/
  788.     SInt16                             ataIconReserved;            /* Reserved to be longword aligned*/
  789.     SInt8 *                            ataLocationIconPtr;            /* -->: Icon Data buffer pointer*/
  790.     SInt8 *                            ataLocationStringPtr;        /* -->: Icon String buffer pointer*/
  791.     UInt16                             Reserved1[18];                /* Reserved for future*/
  792. };
  793. typedef struct ataLocationData ataLocationData;
  794.  
  795. /* ataOSType available*/
  796.  
  797. enum {
  798.     kATAddTypeMacOS                = 0x0001                        /* Blue Mac O/S ddType value*/
  799. };
  800.  
  801. /* The parameter block definition for all other ATA Manager functions.*/
  802. struct ataGeneric {
  803.                                                                 /* Start of cloned common header ataPBHdr*/
  804.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  805.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  806.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  807.     UInt8                             ataPBReserved;                /* Reserved                                        */
  808.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  809.     ProcPtr                         ataPBCallbackPtr;            /* -->: Completion Routine Pointer    */
  810.     OSErr                             ataPBResult;                /* <--: Returned result                */
  811.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  812.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  813.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  814.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  815.     UInt32                             ataPBDeviceID;                /* -->: Device identifier            */
  816.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  817.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  818.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  819.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  820.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  821.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  822.                                                                 /* End of cloned common header ataPBHdr*/
  823.     UInt16                             Reserved[24];                /* Reserved for future*/
  824. };
  825. typedef struct ataGeneric ataGeneric;
  826.  
  827. union ataPB {
  828.     ataIOPB                         ataIOParamBlock;            /* parameter block for I/O*/
  829.     ataBusInquiry                     ataBIParamBlock;            /* parameter block for bus inquiry*/
  830.     ataMgrInquiry                     ataMIParamBlock;            /* parameter block for Manager inquiry*/
  831.     ataAbort                         ataAbortParamBlock;            /* parameter block for abort*/
  832.     ataDrvrRegister                 ataDRParamBlock;            /* parameter block for driver register*/
  833.     ataModifyEventMask                 ataMEParamBlock;            /* parameter block for event mask modify*/
  834.     ataRegAccess                     ataRAParamBlock;            /* parameter block for register access*/
  835.     ataIdentify                     ataDIParamBlock;            /* parameter block for drive identify*/
  836.     ataDevConfiguration             ataDCParamBlock;            /* parameter block for device configuration*/
  837.     ataLocationData                 ataLDParamBlock;            /* parameter block for location icon data*/
  838.                                                                 /*ataManagerInit    ataInitParamBlock;        // parameter block for Manager initialization*/
  839.                                                                 /*ataManagerShutDn    ataSDParamBlock;        // parameter block for Manager shutdown*/
  840.                                                                 /*ataDrvrLoad        ataDLParamBlock;        // parameter block for Driver loading*/
  841.     ataGeneric                         ataGenericParamBlock;        /* parameter block for all other functions*/
  842. };
  843. typedef union ataPB ataPB;
  844.  
  845. /* The ATA Event codes...*/
  846.  
  847. enum {
  848.     kATANullEvent                = 0x00,                            /* Just kidding -- nothing happened*/
  849.     kATAOnlineEvent                = 0x01,                            /* An ATA device has come online*/
  850.     kATAOfflineEvent            = 0x02,                            /* An ATA device has gone offline*/
  851.     kATARemovedEvent            = 0x03,                            /* An ATA device has been removed from the bus*/
  852.     kATAResetEvent                = 0x04,                            /* Someone gave a hard reset to the drive*/
  853.     kATAOfflineRequest            = 0x05,                            /* Someone requesting to offline the drive*/
  854.     kATAEjectRequest            = 0x06,                            /* Someone requesting to eject the drive*/
  855.     kATAUpdateEvent                = 0x07,                            /* Potential configuration change reported by CardServices <SM4>*/
  856.                                                                 /* The following describes bit definitions in the eventMask field of ataDrvrRegister*/
  857.     bATANullEvent                = 1 << kATANullEvent,            /* null event bit*/
  858.     bATAOnlineEvent                = 1 << kATAOnlineEvent,            /* online event bit*/
  859.     bATAOfflineEvent            = 1 << kATAOfflineEvent,        /* offline event bit*/
  860.     bATARemovedEvent            = 1 << kATARemovedEvent,        /* removed event bit*/
  861.     bATAResetEvent                = 1 << kATAResetEvent,            /* reset event bit*/
  862.     bATAOfflineRequest            = 1 << kATAOfflineRequest,        /* offline request event bit*/
  863.     bATAEjectRequest            = 1 << kATAEjectRequest,        /* eject request event bit*/
  864.     bATAUpdateEvent                = 1 << kATAUpdateEvent            /* configuration update event bit*/
  865. };
  866.  
  867. typedef pascal OSErr (*ATADispatchProcPtr)(ataPB *pb);
  868.  
  869. #if GENERATINGCFM
  870. typedef UniversalProcPtr ATADispatchUPP;
  871. #else
  872. typedef ATADispatchProcPtr ATADispatchUPP;
  873. #endif
  874.  
  875. enum {
  876.     uppATADispatchProcInfo = kPascalStackBased
  877.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  878.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ataPB *)))
  879. };
  880.  
  881. #if GENERATINGCFM
  882. #define NewATADispatchProc(userRoutine)        \
  883.         (ATADispatchUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppATADispatchProcInfo, GetCurrentArchitecture())
  884. #else
  885. #define NewATADispatchProc(userRoutine)        \
  886.         ((ATADispatchUPP) (userRoutine))
  887. #endif
  888.  
  889. #if GENERATINGCFM
  890. #define CallATADispatchProc(userRoutine, pb)        \
  891.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppATADispatchProcInfo, (pb))
  892. #else
  893. #define CallATADispatchProc(userRoutine, pb)        \
  894.         (*(userRoutine))((pb))
  895. #endif
  896. extern pascal SInt16 ataManager(ataPB *pb)
  897.  ONEWORDINLINE(0xAAF1);
  898.  
  899. /* Device Error codes: 0xDB42 - 0xDB5F    */
  900.  
  901. enum {
  902.     ATABaseErrCode                = -9406,                        /* Base error code - 0xDB42    */
  903.     ioPending                    = 1,                            /* Asynch I/O in progress status*/
  904.     AT_NRdyErr                    = ATABaseErrCode + 0x01,        /* 0xDB43: Drive not Ready */
  905.     AT_IDNFErr                    = ATABaseErrCode + 0x02,        /* 0xDB44: ID not found */
  906.     AT_DMarkErr                    = ATABaseErrCode + 0x03,        /* 0xDB45: Data mark not found */
  907.     AT_BadBlkErr                = ATABaseErrCode + 0x04,        /* 0xDB46: Bad Block */
  908.     AT_CorDataErr                = ATABaseErrCode + 0x05,        /* 0xDB47: Data was corrected */
  909.     AT_UncDataErr                = ATABaseErrCode + 0x06,        /* 0xDB48: Data was not corrected */
  910.     AT_SeekErr                    = ATABaseErrCode + 0x07,        /* 0xDB49: Seek error */
  911.     AT_WrFltErr                    = ATABaseErrCode + 0x08,        /* 0xDB4A: Write fault */
  912.     AT_RecalErr                    = ATABaseErrCode + 0x09,        /* 0xDB4B: Recalibrate failed */
  913.     AT_AbortErr                    = ATABaseErrCode + 0x0A,        /* 0xDB4C: Command aborted by drive */
  914.     AT_MCErr                    = ATABaseErrCode + 0x0C,        /* 0xDB4E: Media Changed error*/
  915.     ATAPICheckErr                = ATABaseErrCode + 0x0D,        /* 0xDB4F: ATAPI Check condition <06/15/94>*/
  916.                                                                 /* System error codes...Custom Driver Error Codes 0xDB60 - 0xDB6F*/
  917.     DRVRCantAllocate            = ATABaseErrCode + 0x1E,        /* 0xDB60: Allocation error during initialization*/
  918.     NoATAMgr                    = ATABaseErrCode + 0x1F,        /* 0xDB61: MgrInquiry failed => No ATA Manager*/
  919.     ATAInitFail                    = ATABaseErrCode + 0x20,        /* 0xDB62: Mgr Initialization failed*/
  920.     ATABufFail                    = ATABaseErrCode + 0x21,        /* 0xDB63: Device buffer test failure*/
  921.     ATADevUnsupported            = ATABaseErrCode + 0x22,        /* 0xDB64: Device type not supported*/
  922.     ATAEjectDrvErr                = ATABaseErrCode + 0x23,        /* 0xDB65: Could not eject the drive*/
  923.                                                                 /* Manager Error Codes 0xDB70 - 0xDB8F*/
  924.     ATAMgrNotInitialized        = ATABaseErrCode + 0x2E,        /* 0xDB70: Mgr has not been initialized*/
  925.     ATAPBInvalid                = ATABaseErrCode + 0x2F,        /* 0xDB71: The bus base address couldn't be found*/
  926.     ATAFuncNotSupported            = ATABaseErrCode + 0x30,        /* 0xDB72: An unknown function code specified*/
  927.     ATABusy                        = ATABaseErrCode + 0x31,        /* 0xDB73: Selected device is busy*/
  928.     ATATransTimeOut                = ATABaseErrCode + 0x32,        /* 0xDB74: Transaction timeout detected*/
  929.     ATAReqInProg                = ATABaseErrCode + 0x33,        /* 0xDB75: Channel busy; channel is processing another cmd*/
  930.     ATAUnknownState                = ATABaseErrCode + 0x34,        /* 0xDB76: Device status register reflects an unknown state*/
  931.     ATAQLocked                    = ATABaseErrCode + 0x35,        /* 0xDB77: I/O Queue is locked due to previous I/O error.*/
  932.     ATAReqAborted                = ATABaseErrCode + 0x36,        /* 0xDB78: The I/O queue entry was aborted due to an abort req.*/
  933.                                                                 /*            or due to Manager shutdown.*/
  934.     ATAUnableToAbort            = ATABaseErrCode + 0x37,        /* 0xDB79: The I/O queue entry could not be aborted.*/
  935.     ATAAbortedDueToRst            = ATABaseErrCode + 0x38,        /* 0xDB7A: Request aborted due to a device reset command.*/
  936.     ATAPIPhaseErr                = ATABaseErrCode + 0x39,        /* 0xDB7B: Unexpected phase - ***IS THIS VALID ERROR??? <06/15/94>*/
  937.     ATAPITxCntErr                = ATABaseErrCode + 0x3A,        /* 0xDB7C: Overrun/Underrun condition detected*/
  938.     ATANoClientErr                = ATABaseErrCode + 0x3B,        /* 0xDB7D: No client present to handle the event*/
  939.     ATAInternalErr                = ATABaseErrCode + 0x3C,        /* 0xDB7E: MagnumOpus returned an error*/
  940.     ATABusErr                    = ATABaseErrCode + 0x3D,        /* 0xDB7F: Bus error detected on I/O    */
  941.     AT_NoAddrErr                = ATABaseErrCode + 0x3E,        /* 0xDB80: Invalid AT base adress */
  942.     DriverLocked                = ATABaseErrCode + 0x3F,        /* 0xDB81: Current driver must be removed before adding another*/
  943.     CantHandleEvent                = ATABaseErrCode + 0x40,        /* 0xDB82: Particular event couldn't be handled (call others)*/
  944.     ATAMgrMemoryErr                = ATABaseErrCode + 0x41,        /* 0xDB83: Manager memory allocation error    */
  945.     ATASDFailErr                = ATABaseErrCode + 0x42,        /* 0xDB84: Shutdown failure                */
  946.     ATAXferParamErr                = ATABaseErrCode + 0x43,        /* 0xDB85: I/O xfer parameters inconsistent */
  947.     ATAXferModeErr                = ATABaseErrCode + 0x44,        /* 0xDB86: I/O xfer mode not supported */
  948.     ATAMgrConsistencyErr        = ATABaseErrCode + 0x45,        /* 0XDB87: Manager detected internal inconsistency. */
  949.     ATADmaXferErr                = ATABaseErrCode + 0x46,        /* 0XDB88: fatal error in DMA side of transfer */
  950.                                                                 /* Driver loader error Codes 0xDB90 - 0xDBA5*/
  951.     ATAInvalidDrvNum            = ATABaseErrCode + 0x4E,        /* 0xDB90: Invalid drive number from event*/
  952.     ATAMemoryErr                = ATABaseErrCode + 0x4F,        /* 0xDB91: Memory allocation error*/
  953.     ATANoDDMErr                    = ATABaseErrCode + 0x50,        /* 0xDB92: No DDM found on media    */
  954.     ATANoDriverErr                = ATABaseErrCode + 0x51            /* 0xDB93: No driver found on the media    */
  955. };
  956.  
  957. /* ------------------------    Version 1 definition -------------------------------    */
  958.  
  959. enum {
  960.     v1ATABaseErrCode            = 0x0700,                        /* This needs a home somewhere*/
  961.     v1AT_NRdyErr                = 0x01 - v1ATABaseErrCode,        /* 0xF901: -0x1DBE */
  962.     v1AT_IDNFErr                = 0x04 - v1ATABaseErrCode,        /* 0xF904: -0x1DC0 */
  963.     v1AT_DMarkErr                = 0x05 - v1ATABaseErrCode,        /* 0xF905: -0x1DC0 */
  964.     v1AT_BadBlkErr                = 0x06 - v1ATABaseErrCode,        /* 0xF906: -0x1DC0 */
  965.     v1AT_CorDataErr                = 0x07 - v1ATABaseErrCode,        /* 0xF907: -0x1DC0 */
  966.     v1AT_UncDataErr                = 0x08 - v1ATABaseErrCode,        /* 0xF908: -0x1DC0 */
  967.     v1AT_SeekErr                = 0x09 - v1ATABaseErrCode,        /* 0xF909: -0x1DC0 */
  968.     v1AT_WrFltErr                = 0x0A - v1ATABaseErrCode,        /* 0xF90A: -0x1DC0 */
  969.     v1AT_RecalErr                = 0x0B - v1ATABaseErrCode,        /* 0xF90B: -0x1DC0 */
  970.     v1AT_AbortErr                = 0x0C - v1ATABaseErrCode,        /* 0xF90C: -0x1DC0 */
  971.     v1AT_NoAddrErr                = 0x0D - v1ATABaseErrCode,        /* 0xF90D: -0x1D8D */
  972.     v1AT_MCErr                    = 0x0E - v1ATABaseErrCode,        /* 0xF90E: -0x1DC0*/
  973.                                                                 /* System error codes...Custom Driver Error Codes*/
  974.     v1DRVRCantAllocate            = -(v1ATABaseErrCode + 1),        /* 0xF8FF: -0x1D9F*/
  975.     v1NoATAMgr                    = -(v1ATABaseErrCode + 2),        /* 0xF8FE: -0x1D9D*/
  976.     v1ATAInitFail                = -(v1ATABaseErrCode + 3),        /* 0xF8FD: -0x1D9B*/
  977.     v1ATABufFail                = -(v1ATABaseErrCode + 4),        /* 0xF8FC: -0x1D99*/
  978.     v1ATADevUnsupported            = -(v1ATABaseErrCode + 5),        /* 0xF8FB: -0x1c97*/
  979.                                                                 /* Manager Error Codes*/
  980.     v1ATAMgrNotInitialized        = -(v1ATABaseErrCode + 10),        /* 0xF8F6: -0x1D86*/
  981.     v1ATAPBInvalid                = -(v1ATABaseErrCode + 11),        /* 0xF8F5: -0x1D84*/
  982.     v1ATAFuncNotSupported        = -(v1ATABaseErrCode + 12),        /* 0xF8F4: -0x1D82*/
  983.     v1ATABusy                    = -(v1ATABaseErrCode + 13),        /* 0xF8F3: -0x1D80*/
  984.     v1ATATransTimeOut            = -(v1ATABaseErrCode + 14),        /* 0xF8F2: -0x1D7E*/
  985.     v1ATAReqInProg                = -(v1ATABaseErrCode + 15),        /* 0xF8F1: -0x1D7C*/
  986.     v1ATAUnknownState            = -(v1ATABaseErrCode + 16),        /* 0xF8F0: -0x1D7A*/
  987.     v1ATAQLocked                = -(v1ATABaseErrCode + 17),        /* 0xF8EF: -0x1D78*/
  988.     v1ATAReqAborted                = -(v1ATABaseErrCode + 18),        /* 0xF8EE: -0x1D76*/
  989.     v1ATAUnableToAbort            = -(v1ATABaseErrCode + 19),        /* 0xF8ED: -0x1D74*/
  990.     v1ATAAbortedDueToRst        = -(v1ATABaseErrCode + 20)        /* 0xF8EC: -0x1D72*/
  991. };
  992.  
  993. #endif
  994.  
  995. #if PRAGMA_ALIGN_SUPPORTED
  996. #pragma options align=reset
  997. #endif
  998.  
  999. #if PRAGMA_IMPORT_SUPPORTED
  1000. #pragma import off
  1001. #endif
  1002.  
  1003. #ifdef __cplusplus
  1004. }
  1005. #endif
  1006.  
  1007. #endif /* __ATA__ */
  1008.  
  1009.